//
//  MainVC_ContactBook.m
//  liBaQiang
//
//  Created by 奇林刘 on 2018/10/12.
//  Copyright © 2018年 liu. All rights reserved.
//

#import "MainVC_ContactBook.h"
#import "MainVC_ContactBook_ButtonView.h"

@interface MainVC_ContactBook ()

@property (nonatomic, strong) BaseButton *searchButton;
@property (nonatomic, strong) MainVC_ContactBook_ButtonView *companyView;
@property (nonatomic, strong) MainVC_ContactBook_ButtonView *organizationView;

@end

@implementation MainVC_ContactBook

- (void)configSelf {
    self.scrollContentView.fp_backgroundColor(HexadecimalColor(@"#F5F6F8"));
    [self changeScrollMode:ScrollModePortrait];
    [self.scrollContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
        make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
    }];
}

- (void)allocateComponents {
    [self allocateSearchButton];
    [self allocateCompanyView];
    [self allocateOrganizationView];
}

- (void)configComponents {
    [self configSearchButton];
    [self configCompanyView];
    [self configOrganizationView];
}

#pragma mark - usedMethods
- (void)allocateSearchButton {
    self.scrollContentView.fp_addSubview(self.searchButton=[[BaseButton alloc]init]);
    [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.scrollContentView);
        make.top.equalTo(self.scrollContentView).offset(RPX(11));
        make.width.equalTo(@(RPX(345)));
        make.height.equalTo(@(RPX(36)));
    }];

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search"]];
    [self.searchButton addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.searchButton).offset(RPX(11));
        make.left.equalTo(self.searchButton).offset(RPX(147));
        make.width.height.equalTo(@(RPX(14)));
    }];

    UILabel *label = [[UILabel alloc] init]
        .fp_text(@"搜索")
        .fp_font(RPXFont(14))
        .fp_textColor(HexadecimalColor(@"#B3B3B3"));
    [self.searchButton addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageView.mas_right).offset(RPX(10));
        make.centerY.equalTo(imageView);
    }];
}

- (void)allocateCompanyView {
    self.companyView = [[MainVC_ContactBook_ButtonView alloc] initWithHeight:RPX(64)
                                                                  rightTitle:@"邀请"
                                                              rightLogoImage:@"mail"
                                                                   leftTitle:@"北拓科技"
                                                               leftLogoImage:@"index_banner"
                                                               leftTitleFont:BoldRPXFont(16)
                                                               leftLogoWidth:RPX(40)
                                                              leftLogoHeight:RPX(40)];
    self.scrollContentView.fp_addSubview(self.companyView);
    [self.companyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.searchButton.mas_bottom).offset(RPX(11));
        make.centerX.equalTo(self.scrollContentView);
    }];
}

- (void)allocateOrganizationView {
    self.organizationView = [[MainVC_ContactBook_ButtonView alloc] initWithHeight:RPX(49)
                                                                       rightTitle:@"管理"
                                                                   rightLogoImage:@"manage"
                                                                        leftTitle:@"组织构架"
                                                                    leftLogoImage:@"zuZhiGouJia"
                                                                    leftTitleFont:RPXFont(15)
                                                                    leftLogoWidth:RPX(19)
                                                                   leftLogoHeight:RPX(17)];
    self.scrollContentView.fp_addSubview(self.organizationView);
    [self.organizationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.companyView.mas_bottom);
        make.centerX.equalTo(self.scrollContentView);
    }];
}

- (void)configSearchButton {
    self.searchButton.fp_backgroundColor([UIColor whiteColor]).fp_cornerRadius(RPX(4));
}

- (void)configCompanyView {
    [self.companyView.leftButton addTarget:self action:NSSelectorFromString(@"goCompany") forControlEvents:UIControlEventTouchUpInside];
    [self.companyView.rightButton addTarget:self action:NSSelectorFromString(@"goInvite") forControlEvents:UIControlEventTouchUpInside];
}

- (void)configOrganizationView {
    [self.organizationView.leftButton addTarget:self action:NSSelectorFromString(@"goOrganization") forControlEvents:UIControlEventTouchUpInside];
    [self.organizationView.rightButton addTarget:self action:NSSelectorFromString(@"goManage") forControlEvents:UIControlEventTouchUpInside];
}

@end
